﻿using UnityEngine;
using System.Collections;

namespace Battle
{
	public enum ActorType
	{
		Basic,
		Test,
		Tower,
	}

	public partial class BattleFactory
	{
		int actorID = 0;
		public Actor Create (ActorType type)
		{
			Actor a = CreateActor (type);
			Behaviour b = CrateBehaviour (type);
			Fsm f = CreateFsm (type);
			a.Bind (b);
			b.Bind (a, f);
			f.Bind (a, b);

			a.OnInit();

			return a;
		}


		Actor CreateActor (ActorType type)
		{
			if (type == ActorType.Basic) {
				return new Actor ("actor"+(actorID++));
			}
			if (type == ActorType.Test) {
				return new ActorTest ("actor"+(actorID++));
			}
			if (type == ActorType.Tower)
			{
				return new ActorTower("actor"+(actorID++));
			}

			return null;
		}

		Behaviour CrateBehaviour (ActorType type)
		{
			if (type == ActorType.Test) {
				return new BehaviourTest ();
			}
			if (type == ActorType.Tower)
			{
				return new BehaviourTower();
			}

			return null;
		}

		Fsm CreateFsm (ActorType type)
		{


			//Basic------------------------------------------------------------------------------------------------------
			if (type == ActorType.Basic) {

				return CreateBasicFsm();
			}
			//------------------------------------------------------------------------------------------------------

			//Test--------------------------------------------------------------------------------------------------
			if (type == ActorType.Test) {
				return CreateTestFsm();
			}
			//------------------------------------------------------------------------------------------------------

			if (type == ActorType.Tower) {
				return CreateTowerFsm();
			}
			return null;
		}
	}
}